<template>
	<view style="padding-bottom: 100rpx;">
		<view>
			<u-image :src="info.cover" height="400"></u-image>
		</view>
		
		
		<view class="u-padding-30">
			<view class="u-font-weight u-font-30">
				{{info.goodsName}}
			</view>
			<view class="u-type-error u-margin-top-20">
				￥{{info.price}}
			</view>
		</view>
		<u-gap height="10" bg-color="#F6F6F6"></u-gap>
		<view class="u-padding-30">
				{{info.detail}}
		</view>
		<u-gap height="10" bg-color="#F6F6F6"></u-gap>
		
		
		<view>
			
			<u-cell-item :title="info.storeName" @click="goStore"></u-cell-item>
			
			
			
			<view class="u-flex u-row-between u-flex-warp"  style="padding: 0 20rpx;">
				<view @click="go(item)" v-for="(item,index) in list" :key="index" class="boxShadow  u-margin-top-20" style="border-radius: 0 0 20rpx 20rpx;">
					<view>
						<image :src="item.cover" style="width: 350rpx;height: 200rpx;border-radius: 20rpx 20rpx 0 0 ;"></image>
					</view>
					<view class="u-padding-20">
						<view>{{item.goodsName}}</view>
						<view class="u-type-error u-margin-top-20">￥{{item.price}}</view>
					</view>
					
				</view>
			</view>
			
		</view>
		
		<view class="bottomFix   ">
			<u-button @click="call" type="primary"  >
				<u-icon name="phone-fill"></u-icon>
				<text class="u-margin-left-20">联系商家</text>
			</u-button>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
                id:""	,
				info:{},
				goods:[],
				list:[]
			}
		},
		async onLoad(options) {
			if(options.id){
				this.id=options.id;
			    await	this.name()
					this.getGoods()
			}
		},
		methods: {
			goStore(){
				uni.navigateTo({
					url:'./moreDetail?id='+this.id
				})
			},
			go(item){
				uni.navigateTo({
					url:'./detail?id='+item.id
				})
			},
			call() {
				this.$u.post('/user/contactGoods',{
					id:this.id
				}).then(res => {
					uni.makePhoneCall({
						phoneNumber:res
					})
				}).catch(err => {
				   
				})
			},
			name() {
				return new Promise((resolve,reject)=>{
					this.$u.post('/index/goodsDetail', {
						goods_id:this.id
					}).then(res => {
						this.info=res;
						
						resolve(res)
						
					}).catch(err => {
					
					})
					
				})
				
			},
			getGoods(){
				this.$u.post('/index/goods', {
					store_id:this.info.applyId,
				}).then(res => {
					 this.list=	res.filter(item=>item.id!=this.id);
				}).catch(err => {
				
				})
			}
		},
	}
</script>

<style>
</style>
